// mine/pages/teacheredit/index.js
const $api = require("../../../api/mine").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgurl:"https://img.yzcdn.cn/vant/cat.jpeg",
    false:false,
    true:true,
    show:false,
    option1: [],
    currentDate: new Date().getTime(),
    minDate: new Date().getTime(),
    formatter(type, value) {
      if (type === 'year') {
        return `${value}年`;
      } else if (type === 'month') {
        return `${value}月`;
      }
      return value;
    },
    sex:"1",
    teacher_name:"",
    child_birthday:"",
    teacher_info:"",
    prize_winning:"",
    teacher_img:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    var t = this
    t.getTeacherInfo()
  },

  settime(e){
    console.log(2222)
    var t = this
    t.setData({
      show:true
    })
  },
  closetime(e){
    var t = this
    t.setData({
      show:false
    })
  },
  // 获取教师信息
  getTeacherInfo() {
    var t= this,
    data = {
      institution_id:wx.getStorageSync('TeacherClassinfo').institution_id,
      member_id:wx.getStorageSync('memberinfo').member_id
    }
    $api.getTeacherInfo(data).then(res=>{
      console.log(res)
      t.setData({
        info:res.data,
        teacher_name:res.data.teacher_name,
        child_birthday:res.data.start_time
      })
    })
  },
  onChange(event) {
    var t = this
    console.log(event)
    t.setData({
      radio: event.detail,
      sex:event.detail
    });
  },
  // 更新教师基本信息
  modifyTeacherInfo() {
    var t = this,
    data = {
      member_id:wx.getStorageSync('memberinfo').member_id,
      teacher_name:t.data.teacher_name,
      teacher_sex:t.data.sex,
      child_birthday:t.data.child_birthday,
      teacher_info:t.data.teacher_info,
      prize_winning:t.data.prize_winning,
      teacher_img:t.data.teacher_img,
    }
  },
  onChangeteacher_name(e){
    var t = this
    t.setData({
      teacher_name:e.detail
    })
  }
})